home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / Multiprocessing SDK / Sample Code / PowerFrax / sources / HFDocMandelbrot.c next >
Encoding:
C/C++ Source or Header  |  1996-05-01  |  1.8 KB  |  61 lines  |  [TEXT/CWIE]

  1. /************************************************************************************/
  2. /*                                                                                    */
  3. /* PowerFrax                                                                        */
  4. /* ---------                                                                        */
  5. /*                                                                                    */
  6. /*    Motorola compiler command line:                                                    */
  7. /*        mcc HFDocMandelbrot.c -c -i ::includes: -O3                                    */
  8. /*                                                                                    */
  9. /*    © DayStar Digital, Inc. 1995-1996                                                */
  10. /*    All Rights Reserved.                                                            */
  11. /*                                                                                    */
  12. /************************************************************************************/
  13.  
  14. #include "HFDocMandelbrot.h"
  15.  
  16. /*==================================================================================*/
  17. long main( void *params ) {
  18. /* Generates one fractal scan.                                                        */
  19. /* This is the MPWorkFunctionProc called from the tasks.                            */
  20. /* When using the Multiprocessing API Library this function is called from fTask()    */
  21. /* in HFMultiprocessingPPC.c. When the Multiprocessing API Library is not present    */
  22. /* it is called directly from PowerFrax.                                            */
  23.  
  24.     long i;
  25.     double lzc;
  26.     double lzd;
  27.     double lstep;
  28.     double lescape;
  29.     long lwidth;
  30.     char *lresults;
  31.  
  32.     lzc = ((sMandelbrotParamsPtr)params)->zc;
  33.     lzd = ((sMandelbrotParamsPtr)params)->zd;
  34.     lstep = ((sMandelbrotParamsPtr)params)->step;
  35.     lescape = ((sMandelbrotParamsPtr)params)->escape;
  36.     lwidth = ((sMandelbrotParamsPtr)params)->width;
  37.     lresults = ((sMandelbrotParamsPtr)params)->results;
  38.  
  39.     for( i = 0; i < lwidth; i++ ) {
  40.         double za = 0.0;
  41.         double zb = 0.0;
  42.         double ze = 0.0;
  43.         long level = 0;
  44.         while( level < 256 && ze < lescape ) {
  45.             double za2 = za * za;
  46.             double zb2 = zb * zb;
  47.             double zt = za * zb;
  48.             za = za2 - zb2 + lzc;
  49.             zb = zt + zt + lzd;
  50.             ze = za2 + zb2;
  51.             level++;
  52.             }
  53.         *lresults++ = level - 1;
  54.         lzc += lstep;
  55.         }
  56.  
  57.     return( 0 );
  58.     }
  59.  
  60. /*==================================================================================*/
  61.